import java.awt.*
import java.awt.event.*

class PlayerController extends KeyAdapter{
	private boolean pressed;
	private Player target;
	private int tick = 0;
	private int moveTickrate = 5;
	
	public PlayerController(Player target){
		this.target = target;
		pressed = false;
	}
	public void keyPressed(KeyEvent ev){
		int key = ev.getKeyCode();
		pressed = true;
		while(pressed = true){
			tick++;
			if(tick >= moveTickrate){
				switch(key){
					//Down
					case 83: target.move(int 0); break;
						
					//Up
					case 87: target.move(int 1); break;
						
					//Right
					case 68: target.move(int 2); break;
						
					//Left
					case 65: target.move(int 3); break;
				
				}
				tick = 0;
			}
		}
		
	}
	public void keyReleased(KeyEvent evt){
		pressed = false;
	}
}